package reflect;

import reflect.annotations.AutoRunClass;
import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

public class ReflectDemo12 {
    public static void main(String[] args) throws Exception {
        Class c = Person.class;
        boolean a=c.isAnnotationPresent(AutoRunClass.class);
        System.out.println("该类是否被标注："+a);

        Method md=c.getDeclaredMethod("sayHello");
        boolean b=md.isAnnotationPresent(AutoRunMethod.class);
        System.out.println("该方法是否被标注："+b);
        Method[] methods=c.getDeclaredMethods();
        for(Method m:methods){
            if(m.isAnnotationPresent(AutoRunMethod.class)){
                System.out.println(m.getName());
            }
        }
    }
}
